<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!-- JSTL -->
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>教员评价列表</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">

<script src="js/jquery-2.0.3.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="./css/x-admin.css" media="all">
<script src="layui/layui.js" charset="utf-8"></script>

</head>
<body>
	<c:if test="${pd==null}">
		<c:redirect url="TeacherEvaServlet?op=queryByPage"></c:redirect>
	</c:if>
	<div class="x-nav">
		<span class="layui-breadcrumb"> <a><cite>首页</cite></a> <a><cite>教员评价列表</cite></a>
			<a><cite>课程评价列表</cite></a>
		</span> <a class="layui-btn layui-btn-small"
			style="line-height: 1.6em; margin-top: 3px; float: right"
			href="javascript:location.replace(location.href);" title="刷新"><i
			class="layui-icon" style="line-height: 30px">ဂ</i></a>
	</div>
	<div class="x-body">
		<xblock>
		<button class="layui-btn"
			onclick="member_add('添加教员评价','TeacherEvaAdd.jsp','550','550')">
			<i class="layui-icon">&#xe608;</i>添加
		</button>
		<form action="TeacherEvaServlet?op=queryByPage" method="post" style="display: inline-block">
			<div class="layui-input-inline">
	           	<select class="layui-select" name="selectKey" id="selectKey"></select>
			</div>
			<div class="layui-input-inline">
				<input type="hidden" id="select" value="<%=request.getAttribute("selectKey")%>">
				<input type="text" name="empNoQuery" placeholder="请输入要查询的信息"
					id="empNoQuery" autocomplete="off" class="layui-input"
					value="${empNoQuery}" style="width: 300px">
			</div>
			<div class="layui-input-inline" style="width: 50px">
				<button class="layui-btn" type="submit" lay-submit=""
					lay-filter="sreach">
					<i class="layui-icon">&#xe615;</i>
				</button>
			</div>

		</form>

		<span class="x-right" style="line-height: 40px">共有数据：<span
			class="layui-badge"> ${pd.totalCount}</span> 条
		</span></xblock>
		<table class="layui-table">
			<thead>
				<tr>
					<th>评价编号</th>
					<th>员工号</th>
					<th>员工名</th>
					<th>课程名</th>
					<th>教员名</th>
					<th>评价分数</th>
				</tr>
			</thead>

			<!-- 判断是否为空 -->
			<c:if test="${pd!=null}">
				<!-- 遍历 -->
				<c:forEach items="${pd.data}" var="TeacherEva">
					<tbody id="x-img">
						<tr>
							<td>${TeacherEva.evalNo}</td>
							<td>${TeacherEva.empNo}</td>
							<td>${TeacherEva.empName}</td>
							<td>${TeacherEva.courseName}</td>
							<td>${TeacherEva.teacherName}</td>
							<td>${TeacherEva.evalScore}</td>
						</tr>
					</tbody>
				</c:forEach>
			</c:if>
		</table>
		<div id="page"></div>
	</div>

	<script src="./js/x-layui.js" charset="utf-8"></script>
	<script>
	layui.use(['laypage', 'layer'], function(){
		  var laypage = layui.laypage,
		  layer = layui.layer;
		  
		laypage.render({
			elem : 'page',
			theme:'#00BFFF',
			count : ${pd.totalCount},//数据总数，从服务端得到
			curr:${pd.page},//得到当前页，以便向服务端请求对应页的数据。
			limit:${pd.pageSize},//得到每页显示的条数
			layout : [  'prev', 'page', 'next' ],
			jump : function(obj,first) {
				var empNoQuery = $("#empNoQuery").val();
				 //obj包含了当前分页的所有参数，
				//首次不执行
			    if(!first){
			    	location.href = "TeacherEvaServlet?op=queryByPage&page="
						+ obj.curr+"&pageSize="+obj.limit+"&empNoQuery="+empNoQuery;
			    }
			}
		});	

	});

		
		/*用户-添加*/
		function member_add(title, url, w, h) {
			x_admin_show(title, url, w, h);
		}


		/*用户-停用*/
		function member_stop(obj, id) {
			layer.confirm('确认要停用吗？',function(index) {
			//发异步把用户状态进行更改
			$(obj)
					.parents("tr")
					.find(".td-manage")
					.prepend(
							'<a style="text-decoration:none" onClick="member_start(this,id)" href="javascript:;" title="启用"><i class="layui-icon">&#xe62f;</i></a>');
			$(obj)
					.parents("tr")
					.find(".td-status")
					.html(
							'<span class="layui-btn layui-btn-disabled layui-btn-mini">已停用</span>');
			$(obj).remove();
			layer.msg('已停用!', {
				icon : 5,
				time : 1000
			});
		});
	  }

		/*用户-启用*/
		function member_start(obj, id) {
			layer.confirm('确认要启用吗？',function(index) {
			//发异步把用户状态进行更改
			$(obj)
					.parents("tr")
					.find(".td-manage")
					.prepend(
							'<a style="text-decoration:none" onClick="member_stop(this,id)" href="javascript:;" title="停用"><i class="layui-icon">&#xe601;</i></a>');
			$(obj)
					.parents("tr")
					.find(".td-status")
					.html(
							'<span class="layui-btn layui-btn-normal layui-btn-mini">已启用</span>');
			$(obj).remove();
			layer.msg('已启用!', {
				icon : 6,
				time : 1000
			});
		});
	  }
		
	/* 查询选择  */
	var selectKey = ['教员名','课程名'];
	var Key = $("#select").val();
	console.log(Key);
	$(function(){
		$("#selectKey").append("<option value = "+Key+">"+Key+"</option>");
		$.each(selectKey,function(i,o){
			if( o!=Key ){
				console.log(o);
				$("#selectKey").append("<option value = "+o+">"+o+"</option>");
			}
		})
	})

	</script>
</body>
</html>